package key;

import java.awt.*;
import javax.swing.*;
/**
 * 设想失败，窗口在服务器弹出来了
 * @author Administrator
 *
 */
public class Frame extends JFrame {

	private static final long serialVersionUID = 1L;
	
	public Frame(String uname, String uid, String str){
		Container cont = getContentPane();
		setLayout(new GridLayout(4, 1, 50, 20));//网格布局管理器
		cont.setBackground(Color.DARK_GRAY);
		setSize();
		addEle(cont, uname, uid, str);
		setTitle("奇怪的提示");
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setVisible(true);
	}
	
	private void setSizeMINI() {
		Toolkit toolkit = getToolkit();// 获得窗体工具包
		Dimension screenSize = toolkit.getScreenSize();// 获取屏幕大小
		int width = (int) (screenSize.width * 0.3);// 窗体宽度是屏幕宽度的0.3倍
		int height = (int) (screenSize.height * 0.15);// 窗体高度是屏幕高度的0.15倍
		setBounds((int)(screenSize.width * 0.35), (int)(screenSize.height * 0.4), width, height);
		setResizable(false);
	}

	public Frame(String str){
		Container cont = getContentPane();
		setLayout(new GridLayout(1, 1, 50, 20));//网格布局管理器
		cont.setBackground(Color.DARK_GRAY);
		setSizeMINI();
		addEle(cont, str);
		setTitle("奇怪的提示");
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setVisible(true);
	}
	
	private void addEle(Container cont, String str) {
		JLabel jl = new JLabel(str);
		jl.setForeground(Color.LIGHT_GRAY);
		jl.setFont(new Font("", Font.BOLD, 36)); 
		jl.setHorizontalAlignment(SwingConstants.CENTER);
		cont.add(jl);
	}

	private void addEle(Container cont, String uname, String uid, String str) {
		JLabel jl = new JLabel(str);
		jl.setForeground(Color.LIGHT_GRAY);
		jl.setFont(new Font("", Font.BOLD, 36)); 
		jl.setHorizontalAlignment(SwingConstants.CENTER);
		cont.add(jl);
		
		jl = new JLabel("===========当前页面信息==========");
		jl.setForeground(Color.GRAY);
		jl.setFont(new Font("", Font.BOLD, 24)); 
		jl.setHorizontalAlignment(SwingConstants.CENTER);
		cont.add(jl);
		
		jl = new JLabel("uname:"+uname);
		jl.setForeground(Color.WHITE);
		jl.setFont(new Font("", Font.BOLD, 28)); 
		jl.setHorizontalAlignment(SwingConstants.CENTER);
		cont.add(jl);
		
		jl = new JLabel("uid:"+uid);
		jl.setForeground(Color.WHITE);
		jl.setFont(new Font("", Font.BOLD, 28)); 
		jl.setHorizontalAlignment(SwingConstants.CENTER);
		cont.add(jl);
	}
	
	private void setSize() {
		Toolkit toolkit = getToolkit();// 获得窗体工具包
		Dimension screenSize = toolkit.getScreenSize();// 获取屏幕大小
		int width = (int) (screenSize.width * 0.4);// 窗体宽度是屏幕宽度的0.4倍
		int height = (int) (screenSize.height * 0.3);// 窗体高度是屏幕高度的0.3倍
		setBounds((int)(screenSize.width * 0.3), (int)(screenSize.height * 0.35), width, height);
		setResizable(false);
	}
	
}
